package com.demo2do.fms.admin.dao.business;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.demo2do.fms.entity.business.shipment.ShipmentOrder;
import com.demo2do.fms.entity.business.shipment.ShipmentOrderItem;

/**
 *
 * @author Ark
 *
 */
@Dao("hibernate")
public interface ShipmentOrderDao {
    
    /**
     * list shipment_order by dispatch_order_id
     * 
     * @param dispatchOrderId
     * @return
     */
    @Query("FROM ShipmentOrder WHERE dispatchOrderId = :dispatchOrderId")
    public List<ShipmentOrder> listShipmentOrder(@Variable("dispatchOrderId") Long dispatchOrderId);
    
    /**
     * list shipment_orders by shipment_number
     * 
     * @param shipmentNumber
     * @return
     */
    @Query("FROM ShipmentOrder WHERE shipmentNumber = :shipmentNumber")
    public List<ShipmentOrder> listShipmentOrder(@Variable("shipmentNumber")String shipmentNumber);

    /**
     * list shipment_orders by dispatch_order_id OR shipment_number
     * 
     * @param dispatchOrderId
     * @param shipmentNumber
     * @return
     */
    @Query("FROM ShipmentOrder WHERE dispatchOrderId = :dispatchOrderId OR shipmentNumber = :shipmentNumber")
    public List<ShipmentOrder> listShipmentOrder(@Variable("dispatchOrderId")Long dispatchOrderId, @Variable("shipmentNumber")String shipmentNumber);
    
    /**
     * @param dispatchOrderIds
     * @return
     */
    @Query("FROM ShipmentOrder WHERE dispatchOrderId in (:dispatchOrderIds)")
    public List<ShipmentOrder> listShipmentOrder(@Variable("dispatchOrderIds") List<Long> dispatchOrderIds);
    
    /**
     * list shipment_order_item by order_id and shipment_number
     * 
     * @param orderId
     * @param shipmentNumber
     * @return
     */
    @Query("FROM ShipmentOrderItem WHERE orderId = :orderId AND shipmentNumber = :shipmentNumber")
    public List<ShipmentOrderItem> listShipmentOrderItem(@Variable("orderId")Long orderId, @Variable("shipmentNumber")String shipmentNumber);
    
}
